\documentclass[a4paper,UTF8]{article}
\usepackage{ctex}
\usepackage{tikz}
\begin{document}
	\begin{tikzpicture}
		
		% 画坐标系
		\draw (0,-3) [->, thick]-- (0,3) node (yaxis) [above] {y};
		\draw (0,0) [->, thick]-- (9,0) node (yaxis) [above] {x};
		\foreach \x/\y in {1/1,2/2,3/1,4/-2,5/1,6/2,7/1,8/-2,9/1} {
			\fill (\x,\y) circle (2pt);
		}
		
		\foreach \x in {1,2,3,4,5,6,7,8,9}{
			\node at (\x,0) [below] {\x};
		}
		\foreach \x in {1,2,3,4,5}{
			\draw (\x,0) -- (\x, 2pt);
		}	
		\foreach \y in {-3,-2,-1,0,1,2,3}{
			\node at (0,\y) [left] {\y};
		}
		\foreach \y in {-3,-2,-1,1,2,3}{
			\draw (0,\y) -- (2pt,\y);
		}
		\draw [red,smooth,domain=1:9] plot function {0.0031746031746031746*x**8-0.13015873015873017*x**7+2.244444444444444*x**6-21.11111111111111*x**5+117.3777777777778*x**4 -390.37777777777785*x**3+747.3746031746031*x**2-740.3809523809525*x+286.0};
		
		
		\draw [blue,smooth,domain=1:2] plot function {1+1.268041237113402*(x-1)-0.26804123711340205*(x-1)**3};
		
		\draw [blue,smooth,domain=2:3] plot function {2+0.463917525773196*(x-2)-0.8041237113402062*(x-2)**2-0.6597938144329897*(x-2)**3};
		
		\draw [blue,smooth,domain=3:4] plot function {1-3.1237113402061856*(x-3)-2.783505154639175*(x-3)**2 + 2.9072164948453607*(x-3)**3};
		
		\draw [blue,smooth,domain=4:5] plot function {-2+0.030927835051546726*(x-4)+5.9381443298969065*(x-4)**2- 2.9690721649484533*(x-4)**3};
		
		\draw [blue,smooth,domain=5:6] plot function {1+3*(x-5)-2.9690721649484533*(x-5)**2+0.9690721649484534*(x-5)**3};
		
		\draw [blue,smooth,domain=6:7] plot function {2-0.030927835051546282*(x-6)-0.06185567010309301*(x-6)**2- 0.9072164948453607*(x-6)**3};
		
		\draw [blue,smooth,domain=7:8] plot function {1-2.8762886597938144*(x-7)-2.783505154639175*(x-7)**2+ 2.6597938144329896*(x-7)**3};
		
		\draw [blue,smooth,domain=8:9] plot function {-2-0.463917525773196*(x-8)+5.195876288659794*(x-8)**2- 1.731958762886598*(x-8)**3};
		
		% 一阶导数
		\draw [blue,smooth,domain=1:2] plot function {1+1.268041237113402-0.26804123711340205*3*(x-1)**2};
		
		\draw [blue,smooth,domain=2:3] plot function {2+0.463917525773196-0.8041237113402062*2*(x-2)-0.6597938144329897*3*(x-2)**2};
		
		\draw [blue,smooth,domain=3:4] plot function {1-3.1237113402061856*(x-3)-2.783505154639175*(x-3)**2 + 2.9072164948453607*(x-3)**3};
		
		\draw [blue,smooth,domain=4:5] plot function {-2+0.030927835051546726*(x-4)+5.9381443298969065*(x-4)**2- 2.9690721649484533*(x-4)**3};
		
		\draw [blue,smooth,domain=5:6] plot function {1+3*(x-5)-2.9690721649484533*(x-5)**2+0.9690721649484534*(x-5)**3};
		
		\draw [blue,smooth,domain=6:7] plot function {2-0.030927835051546282*(x-6)-0.06185567010309301*(x-6)**2- 0.9072164948453607*(x-6)**3};
		
		\draw [blue,smooth,domain=7:8] plot function {1-2.8762886597938144*(x-7)-2.783505154639175*(x-7)**2+ 2.6597938144329896*(x-7)**3};
		
		\draw [blue,smooth,domain=8:9] plot function {-2-0.463917525773196*(x-8)+5.195876288659794*(x-8)**2- 1.731958762886598*(x-8)**3};
	\end{tikzpicture}
\end{document}